import java.util.Scanner;

public class Solution {
    public int[] plusOne(int[] digits){
        for (int i = digits.length - 1; i >= 0; i--) {
            if(digits[i] != 9){
                digits[i]++;
                for (int j = i + 1; j < digits.length; j++) {
                    digits[j] = 0;
                }
                return digits;
            }
        }
        //数组的所有元素都为9
        int[] ans = new int[digits.length + 1];
        ans[0] = 1;
        return ans;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()){
            int size = scanner.nextInt();
            int[] digits = new int[size];
            for (int i = 0; i < size; i++) {
                digits[i] = scanner.nextInt();
            }
            Solution solution = new Solution();
            int[] array = solution.plusOne(digits);
            for (int num : array) {
                System.out.print(num);
            }
        }
    }
}
